home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC06DLog / DLog1.asm < prev    next >
Encoding:
Assembly Source File  |  1990-05-25  |  34.0 KB  |  887 lines  |  [04] ASCII Text (0x0000)

  1. *******************************************************************************
  2. *
  3. * DLog1
  4. *
  5. * (C)  Copyright Apple Computer, Inc. 1988-1990
  6. * All rights reserved.
  7. *
  8. * Developer Technical Support Apple II Sample Code
  9. *
  10. * by Jim Mensch
  11. *
  12. * Demo of the Apple IIgs Dialog manager. This program shows how to create and 
  13. * work with standard dialog boxes, both Modal and Modeless. It also has a demo
  14. * of simple alerts. The dialogs used are from the examples in the toolbox ref
  15. * manual volume 1. The Modal example implements a save current value feature.
  16. *
  17. *******************************************************************************
  18. **********************************************************************
  19. *                                                                    *
  20. *             Apple IIGS Source Code Sampler, Volume I               *
  21. *                                                                    *
  22. *           Copyright (c) Apple Computer, Inc. 1988-1990             *
  23. *                       All Rights Reserved                          *
  24. *                                                                    *
  25. *            Written by Apple II Developer Tech Support              *
  26. *                                                                    *
  27. *                                                                    *
  28. *                                                                    *
  29. *  ----------------------------------------------------------------  *
  30. *                                                                    *
  31. *     This program and its derivatives are licensed only for         *
  32. *     use on Apple computers.                                        *
  33. *                                                                    *
  34. *     Works based on this program must contain and                   *
  35. *     conspicuously display this notice.                             *
  36. *                                                                    *
  37. *     This software is provided for your evaluation and to           *
  38. *     assist you in developing software for the Apple IIGS           *
  39. *     computer.                                                      *
  40. *                                                                    *
  41. *     DISCLAIMER OF WARRANTY                                         *
  42. *                                                                    *
  43. *     THE SOFTWARE IS PROVIDED "AS IS" WITHOUT                       *
  44. *     WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,               *
  45. *     WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS             *
  46. *     FOR ANY PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO             *
  47. *     THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH            *
  48. *     YOU.  SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU (AND            *
  49. *     NOT APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE)               *
  50. *     ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING,             *
  51. *     REPAIR OR CORRECTION.                                          *
  52. *                                                                    *
  53. *     Apple does not warrant that the functions                      *
  54. *     contained in the Software will meet your requirements          *
  55. *     or that the operation of the Software will be                  *
  56. *     uninterrupted or error free or that defects in the             *
  57. *     Software will be corrected.                                    *
  58. *                                                                    *
  59. *     SOME STATES DO NOT ALLOW THE EXCLUSION                         *
  60. *     OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY              *
  61. *     NOT APPLY TO YOU.  THIS WARRANTY GIVES YOU SPECIFIC            *
  62. *     LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS                *
  63. *     WHICH VARY FROM STATE TO STATE.                                *
  64. *                                                                    *
  65. *                                                                    *
  66. **********************************************************************
  67.                     eject
  68.                     
  69.                     case   on
  70.  
  71.                     copy 2/ainclude/E16.Quickdraw
  72.                     copy 2/ainclude/E16.Memory
  73.                     copy 2/ainclude/E16.Window
  74.                     copy 2/ainclude/E16.Dialog
  75.                     mcopy macros/dlog1.macros
  76.  
  77. DPHandle            gequ 0               ; handle to Tool Direct Page area
  78. DPPointer           gequ DPHandle+4      ; Pointer to Tool Direct Page area
  79. DeRef               gequ DPPointer+4     ; Temprary Handle dereference area
  80. ScreenMode          gequ mode640         ; used to set scan line SCB
  81. ScreenWidth         gequ 640             ; used to set mouse clamps                
  82.  
  83. CloseItem           gequ 255             ; menu item number for close item
  84.  
  85.                     EJECT
  86. *******************************************************************************
  87. *
  88. DLog1               start
  89. *
  90. * Description:      This is the main routine of the program. It simply calls
  91. *                   all the other major parts of the program.
  92. *
  93. *
  94. * Inputs:           None
  95. *
  96. * Outputs:          None
  97. *
  98. * External Refs:
  99. *                   Import InitTools, InitApp, EventLoop, CloseTools, QuitParms
  100. *
  101. * Entry Points:     None
  102. *
  103. *******************************************************************************
  104.  
  105.  
  106.                     jsr InitTools
  107.                     jsr InitApp
  108.  
  109.                     _ShowCursor
  110.  
  111.                     jsr EventLoop
  112.                     jsr CloseTools
  113.  
  114.                     _Quit QuitParms
  115.  
  116.                     end
  117.  
  118.                     EJECT
  119. *******************************************************************************
  120. *
  121. Globals             data
  122. *
  123. * Description:      Global data for use in all routines of this demo. This area
  124. *                   also contains the data used by StandardLib.asm              
  125. *
  126. *
  127. * Inputs:           None
  128. *
  129. * Outputs:          None
  130. *
  131. * External Refs:    None
  132. *
  133. * Entry Points:
  134. *                   Export QuitParms    ; used by Main
  135. *
  136. *******************************************************************************
  137. *
  138. * Standard global data
  139. *
  140. *******************************************************************************
  141.  
  142. TitleString         str 'Apple IIgs Dialog Mgr Example Application'
  143. AutString           str 'By Mensch Apple DTS -- Version: 3.0'
  144. VersString          str 'Copyright (c) 1988-1990'
  145.  
  146. MenuHeight          ds 2                ; Stored height of menu bar
  147. MyID                ds 2                ; Application ID
  148. MyDP                ds 2                ; My direct page storage
  149.  
  150. QuitFlag            ds 2
  151. QuitParms           dc i4'0'            ; Pathname of next app
  152.                     dc i2'$00'          ; flags
  153.  
  154. EventRecord         ANOP
  155. EventWhat           ds 2
  156. EventMessage        ds 4
  157. EventWhen           ds 4
  158. EventWhere          ds 4
  159. EventModifiers      ds 2
  160. TaskData            ds 4
  161. TaskMask            dc i4'$0000FFFF'
  162.  
  163.                     EJECT
  164. *******************************************************************************
  165. *
  166. * Application specific global data
  167. *
  168. *******************************************************************************
  169.  
  170. ; This is a list of pointers to the text that is used to create our menus. It
  171. ; is used by InitApp to find all of the menu templates and use them to create
  172. ; our menubar. This loop loads MenuPtrLen-4 into an index, gets the
  173. ; corresponding menu template pointer in this table, and uses that in a
  174. ; NewMenu call. It then decrements the index by 4, and repeats the procees
  175. ; until the index is negative.
  176.  
  177. MenuPtr             dc i4'AppMenu'
  178.                     dc i4'FileMenu'
  179.                     dc i4'EditMenu'
  180. MenuPtrLen          equ *-MenuPtr
  181.  
  182.  
  183. ; Menu list: menu items should be numbered consecutivly starting from 250.
  184. ; As a convention, use 256 as about and 257 as Quit.
  185.  
  186. AppMenu             dc c'$$@\XN1',h'0D'
  187.                     dc c'--About Simple Dialog...\N256V',h'00'
  188.                     dc c'.'
  189. FileMenu            dc c'$$  File  \N2',h'00'
  190.                     dc c'--Modal Dialog Sample...\N258',h'00'
  191.                     dc c'--Modeless Dialog Sample...\N259',h'00'
  192.                     dc c'--Close\N255DV',h'00'
  193.                     dc c'--Quit\N257*Qq',h'0D'
  194.                     dc c'.'
  195. EditMenu            dc c'$$  Edit  \N3',h'00'
  196.                     dc c'--Undo\N250*ZzVD',h'00'
  197.                     dc c'--Cut\N251*XxD',h'00'
  198.                     dc c'--Copy\N252*CcD',h'00'
  199.                     dc c'--Paste\N253*VvD',h'00'
  200.                     dc c'--Clear\N254D',h'00'
  201.                     dc c'.'
  202.  
  203. ; ModalTemplate is the template described in the Toolbox reference to be used
  204. ; with the getNewModalDialog call
  205.  
  206. ModalTemplate       ANOP
  207.                     dc i2'30,30,120,330'                    ; for 320 use 30,30,130,290
  208.                     dc i2'$FFFF'        ; visible
  209.                     dc i4'0'
  210.                     dc i4'MTOKButton'   ; the ok button for this dialog
  211.                     dc i4'MTCancelButton'                   ; cancel button
  212.                     dc i4'MTTitle1'     ; title string of the dialog
  213.                     dc i4'MTTitle2'     ; Title string of the Edit item
  214.                     dc i4'MTRadio1'     ; Standard paper item
  215.                     dc i4'MTRadio2'     ; legal pad item
  216.                     dc i4'MTCheck'      ; stop printing item
  217.                     dc i4'MTEdit'       ; edit box for page title
  218.                     dc i4'0'            ; end of the item list
  219.  
  220. OKBTitle            str 'OK'
  221. CancelBTitle        str 'Cancel'
  222. MTTitle1Str         str 'Print the document'
  223. MTTitle2Str         str 'Title:'
  224. MTCheckStr          str 'Stop printing after each page'
  225. MTRadio1Str         str '8 1/2" x 11" paper'
  226. MTRadio2Str         str '8 1/2" x 14" paper'
  227. MTDefaultStr        ds 65
  228. MTOKButton          ANOP
  229.                     dc i2'1'            ; Item ID
  230.                     dc i2'30,220,43,285'                    ; Item rectangle
  231.                     dc i2'buttonItem'   ; Item type
  232.                     dc i4'OKBTitle'     ; Item Descriptor ( title )
  233.                     dc i2'0'            ; Initial value
  234.                     dc i2'0'            ; item flag ( 0 for default )
  235.                     dc i4'0'            ; no color table
  236.  
  237. MTCancelButton      ANOP
  238.                     dc i2'2'
  239.                     dc i2'10,220,23,285'
  240.                     dc i2'buttonItem'
  241.                     dc i4'CancelBTitle'
  242.                     dc i2'0'
  243.                     dc i2'0'            ; item flag
  244.                     dc i4'0'            ; no color table
  245.  
  246. MTTitle1            ANOP
  247.                     dc i2'3'
  248.                     dc i2'10,10,20,239'
  249.                     dc i2'statText+itemDisable'
  250.                     dc i4'MTTitle1Str'
  251.                     dc i2'0'
  252.                     dc i2'0'            ; item flag
  253.                     dc i4'0'            ; no color table
  254.  
  255. MTTitle2            ANOP
  256.                     dc i2'4'
  257.                     dc i2'67,10,77,60'
  258.                     dc i2'statText+itemDisable'
  259.                     dc i4'MTTitle2Str'
  260.                     dc i2'0'
  261.                     dc i2'0'            ; item flag
  262.                     dc i4'0'            ; no color table
  263.  
  264. MTRadio1            ANOP
  265.                     dc i2'5'
  266.                     dc i2'25,10,34,239'
  267.                     dc i2'radioItem'
  268.                     dc i4'MTRadio1Str'
  269. MTRad1Def           dc i2'1'            ; default to on
  270.                     dc i2'1'            ; family 1
  271.                     dc i4'0'
  272.  
  273. MTRadio2            ANOP
  274.                     dc i2'6'
  275.                     dc i2'35,10,49,239'
  276.                     dc i2'radioItem'
  277.                     dc i4'MTRadio2Str'
  278. MTRad2Def           dc i2'0'            ; default to off                
  279.                     dc i2'1'            ; family 1
  280.                     dc i4'0'
  281.  
  282. MTCheck             ANOP
  283.                     dc i2'7'
  284.                     dc i2'50,10,64,280'
  285.                     dc i2'checkItem'
  286.                     dc i4'MTCheckStr'
  287. MTCheckDef          dc i2'0'
  288.                     dc i2'0'
  289.                     dc i4'0'
  290.  
  291. MTEdit              ANOP
  292.                     dc i2'8'
  293.                     dc i2'65,65,80,280'
  294.                     dc i2'editLine'
  295.                     dc i4'MTDefaultStr'
  296.                     dc i2'60'           ; max length
  297.                     dc i2'0'
  298.                     dc i4'0'
  299.  
  300. BColorTab           ANOP                ; color table for use with color buttons
  301.                     dc i2'$0050'        ; bttnOutline blue/red
  302.                     dc i2'$00F0'        ; bttnNorBack white background
  303.                     dc i2'$00A0'        ; bttnSelBack yellow/green
  304.                     dc i2'$00F0'        ; bttnNorText Black text on White
  305.                     dc i2'$00A0'        ; bttnSelText Black on yellow/green
  306. ;
  307. ;   Modeless Dialog Data 
  308. ;
  309. ModelessPtr         ds 4
  310. MLRect              dc i2'30,30,110,330'                    ; for 320 use 30,30,130,290
  311. MLTitle             str 'Change'
  312. DLogHit             ds 4
  313. DLogItemHit         ds 4
  314.  
  315.                     end
  316.  
  317.                     copy StandardLib.asm
  318.                     
  319.                     EJECT
  320. *******************************************************************************
  321. *
  322. InitApp             start
  323. *
  324. * Description:      This routine is called once after the tools are started.
  325. *                   This is where you would create objects your program will
  326. *                   need at the very start, or initialize variables that require
  327. *                   an Initial default value.
  328. *
  329. *
  330. * Inputs:           None
  331. *
  332. * Outputs:          None
  333. *
  334. * External Refs:
  335.                     using Globals
  336. *
  337. * Entry Points:     None
  338. *
  339. *******************************************************************************
  340.  
  341.                     Stz QuitFlag        ; initialize the quit flag
  342.                     stz ModelessPtr     ; zero the modeless pointer to signify
  343.                     stz ModelessPtr+2   ; it is not already up
  344.  
  345.                     rts
  346.                     end
  347.  
  348.  
  349.                     EJECT
  350. *******************************************************************************
  351. *
  352. EventLoop           start
  353. *
  354. * Description:      Main event loop. Handles all user events and calls various
  355. *                   routines based on them. This routine ends when the user 
  356. *                   selects Quit.
  357. *                   
  358. *
  359. *
  360. * Inputs:           None
  361. *
  362. * Outputs:          None
  363. *
  364. * External Refs:
  365.                     using Globals
  366. *                   Import ModelessEvent
  367. *                   Import MenuSelect
  368. *                   Import doClose
  369. *                   Import Ignore
  370. *
  371. * Entry Points:     None
  372. *
  373. *******************************************************************************
  374.                     
  375.                     PushWord #0         ; room for result
  376.                     PushWord #$FFFF     ; handle all tasks
  377.                     PushLong #EventRecord ; pointer to event record storage
  378.                     _TaskMaster
  379.                     
  380. ; Now that an event has occured we have to see if it is a dialog event. I do
  381. ; this by setting up a table of all possible events and specifying for each
  382. ; event type, whether it should be tested as a dialog event. If it turns out to
  383. ; be a dialog event, I change the EventType variable to 15 (app event 4)
  384. ; and proceed with my normal event dispatch. This will cause the event to be
  385. ; passed to my dialog event handler.
  386.  
  387.                     pla                 ; get the event type
  388.                     sta EventType       ; save it for after dialog select
  389.                     tax                 ; use as index into dlog event flags
  390.                     lda DLogEFlags,x    ; to see if its an event dialogs
  391.                     and #$00FF          ; might want
  392.                     bne EL0010          ; nope branch around this!
  393.  
  394.                     PushWord #0
  395.                     PushLong #EventRecord
  396.                     _IsDialogEvent
  397.                     pla
  398.                     beq EL0010          ; false do nothing
  399.                     lda #15             ; if true dispatch application event
  400.                     sta EventType       ; #15 to signal a dialog event
  401. EL0010              ANOP
  402.                     lda EventType
  403.                     asl a               ; multiply by 2
  404.                     tax
  405.                     jsr (TaskTable,x)
  406.  
  407.                     lda QuitFlag
  408.                     beq EventLoop
  409.  
  410.                     rts
  411. EventType           ds 2
  412. TaskTable           dc i2'ModelessEvent'                    ; 0 Null
  413.                     dc i2'Ignore'       ; 1 MouseDown
  414.                     dc i2'Ignore'       ; 2 Mouse Up
  415.                     dc i2'Ignore'       ; 3 KeyDown
  416.                     dc i2'Ignore'       ; 4 Undefined
  417.                     dc i2'Ignore'       ; 5 AutoKey
  418.                     dc i2'Ignore'       ; 6 Update
  419.                     dc i2'Ignore'       ; 7 undefined
  420.                     dc i2'Ignore'       ; 8 activate
  421.                     dc i2'Ignore'       ; 9 Switch
  422.                     dc i2'Ignore'       ; 10 desk acc
  423.                     dc i2'Ignore'       ; 11 device driver
  424.                     dc i2'Ignore'       ; 12 ap
  425.                     dc i2'Ignore'       ; 13 ap
  426.                     dc i2'Ignore'       ; 14 ap
  427.                     dc i2'ModelessEvent'                    ; 15 ap
  428.                     dc i2'Ignore'       ; TASK 0 indesk
  429.                     dc i2'MenuSelect'   ; TASK 1 in menuBar
  430.                     dc i2'Ignore'       ; TASK 2 in system window
  431.                     dc i2'Ignore'       ; TASK 3 in content
  432.                     dc i2'Ignore'       ; TASK 4 in Drag
  433.                     dc i2'Ignore'       ; TASK 5 in grow
  434.                     dc i2'doClose'      ; TASK 6 in goaway
  435.                     dc i2'Ignore'       ; TASK 7 in zoom
  436.                     dc i2'Ignore'       ; TASK 8 in info bar
  437.                     dc i2'MenuSelect'   ; TASK 9 in special menu
  438.                     dc i2'Ignore'       ; TASK 10 in NDA
  439.                     dc i2'Ignore'       ; TASK 11 in frame
  440.                     dc i2'Ignore'       ; TASK 12 in drop           
  441. DLogEFlags          ANOP
  442.                     dc i1'0'            ; null event
  443.                     dc i1'0'            ; 1 MouseDown
  444.                     dc i1'0'            ; 2 Mouse Up
  445.                     dc i1'0'            ; 3 KeyDown
  446.                     dc i1'1'            ; 4 Undefined
  447.                     dc i1'0'            ; 5 AutoKey
  448.                     dc i1'0'            ; 6 Update
  449.                     dc i1'1'            ; 7 undefined
  450.                     dc i1'0'            ; 8 activate
  451.                     dc i1'1'            ; 9 Switch
  452.                     dc i1'1'            ; 10 desk acc
  453.                     dc i1'1'            ; 11 device driver
  454.                     dc i1'1'            ; 12 ap
  455.                     dc i1'1'            ; 13 ap
  456.                     dc i1'1'            ; 14 ap
  457.                     dc i1'0'            ; 15 ap
  458.                     dc i1'1'            ; TASK 0 indesk
  459.                     dc i1'1'            ; TASK 1 in menuBar
  460.                     dc i1'1'            ; TASK 2 in system window
  461.                     dc i1'0'            ; TASK 3 in content
  462.                     dc i1'1'            ; TASK 4 in Drag
  463.                     dc i1'1'            ; TASK 5 in grow
  464.                     dc i1'1'            ; TASK 6 in goaway
  465.                     dc i1'1'            ; TASK 7 in zoom
  466.                     dc i1'1'            ; TASK 8 in info bar
  467.                     dc i1'1'            ; TASK 9 in special menu
  468.                     dc i1'1'            ; TASK 10 in NDA
  469.                     dc i1'1'            ; TASK 11 in frame
  470.                     dc i1'1'            ; TASK 12 in drop           
  471.                     end
  472.  
  473.  
  474.                     EJECT
  475. *******************************************************************************
  476. *
  477. MenuSelect          start
  478. *
  479. * Description:      This routine is called when TaskMaster returns a menu
  480. *                   event. It takes the menu item that was hit and calculates
  481. *                   an offset into the menu dispatch table. It then calls that
  482. *                   routine and unhilites the menu when it is done.
  483. *
  484. * Inputs:           TaskData holds menu item selected.
  485. *
  486. * Outputs:          NONE
  487. *
  488. * External Refs:
  489. *                   Import ignore
  490. *                   Import doAbout
  491. *                   Import doQuit
  492. *                   Import Ignore
  493. *                   Import doModal
  494. *                   Import ShowModeless
  495. *                   Import doClose
  496. *
  497. * Entry Points:     NONE
  498. *
  499. *******************************************************************************
  500.                     using Globals
  501.  
  502.                     lda TaskData        ; Get the ID of the menu item selected.
  503.                     sec                 ; Turn it into an index by subtracting
  504.                     sbc #250            ; the starting ID number (25) and mul-
  505.                     asl a               ; tiplying by 2 (each table entry con-
  506.                     tax                 ; sists of 2 bytes).
  507.                     jsr (MenuTable,x)   ; Call the routine behind it.
  508.  
  509.                     PushWord #0         ; Routine done - unhilite the menubar.
  510.                     PushWord TaskData+2
  511.                     _HiLiteMenu
  512.  
  513.                     rts
  514.  
  515. MenuTable           dc i2'Ignore'       ; Undo Item (250)
  516.                     dc i2'Ignore'       ; cut
  517.                     dc i2'Ignore'       ; copy
  518.                     dc i2'Ignore'       ; paste
  519.                     dc i2'Ignore'       ; clear
  520.                     dc i2'doClose'      ; close 
  521.                     dc i2'doAbout'      ; about shell...
  522.                     dc i2'doQuit'       ; quit selected
  523.                     dc i2'doModal'      ; example Modal Dialog
  524.                     dc i2'ShowModeless' ; example Modeless Dialog
  525.  
  526.                     end
  527.  
  528.                     EJECT
  529. *******************************************************************************
  530. *
  531. Ignore              start
  532. *
  533. * Description:      Called when I want to ignore an event.
  534. *
  535. *
  536. * Inputs:           NONE
  537. *
  538. * Outputs:          NONE
  539. *
  540. * External Refs:    NONE
  541. *
  542. * Entry Points:     NONE
  543. *
  544. *******************************************************************************
  545.  
  546.                     rts
  547.                     end
  548.  
  549.  
  550.                     EJECT
  551. *******************************************************************************
  552. *
  553. doQuit              start
  554. *
  555. * Description:      Sets the quitflag to $FFFF so that the event loop will
  556. *                   know that the user wants to stop this app.
  557. *
  558. *
  559. * Inputs:           None
  560. *
  561. * Outputs:          None
  562. *
  563. * External Refs:    None
  564. *
  565. * Entry Points:     None
  566. *
  567. *******************************************************************************
  568.                     using Globals
  569.  
  570.                     lda #$FFFF
  571.                     sta QuitFlag
  572.                     rts
  573.                     end
  574.  
  575.                     EJECT
  576. *******************************************************************************
  577. *
  578. doClose             start
  579. *
  580. * Description:      When the user selects the Close box of our modeless dialog or
  581. *                   the close menu Item. This routine will be called to put the dialog
  582. *                   away and clear the pointer to 0 to indicate that no Modeless dialog
  583. *                   is currently active.
  584. *
  585. *
  586. * Inputs:           None
  587. *
  588. * Outputs:          None
  589. *
  590. * External Refs:    None
  591. *
  592. * Entry Points:     None
  593. *
  594. *******************************************************************************
  595.                     using Globals
  596.  
  597.                     PushLong ModelessPtr
  598.                     _CloseDialog        ; dump the dialog box
  599.  
  600.                     stz ModelessPtr     ; zero the pointer to show that it 
  601.                     stz ModelessPtr+2   ; is put away!
  602.  
  603.                     PushWord #CloseItem ; windows gone diable close
  604.                     _DisableMItem       ; 
  605.  
  606.                     rts
  607.                     end
  608.  
  609.                     EJECT
  610. *******************************************************************************
  611. *
  612. ModelessEvent       start
  613. *
  614. * Description:      This routine will be called every time an event occurs that
  615. *                   a modeless dialog should hear about. First, this routine 
  616. *                   checks to see if any modeless dialog exists, if not it  
  617. *                   exits. If one does exist, this routine handles the event.
  618. *
  619. *
  620. * Inputs:           None  (All info passed in the event record)                 
  621. *
  622. * Outputs:          None
  623. *
  624. * External Refs:    None
  625. *
  626. * Entry Points:     None
  627. *
  628. *******************************************************************************
  629.                     using Globals
  630.  
  631.                     lda ModelessPtr
  632.                     ora ModelessPtr+2   ; test to see if dialog exists first
  633.                     bne MLE0010         ; if non-zero then its up
  634.                     rts
  635.  
  636. MLE0010             ANOP
  637.                     PushWord #0         ; room for result
  638.                     PushLong #EventRecord ; pointer to the event that occured
  639.                     PushLong #DLogHit   ; Storage for the dialogs grafport 
  640.                     PushLong #DLogItemHit ; pointer to the item that was hit
  641.                     _DialogSelect
  642.                     pla                 ; anything hit?
  643.                     bne MLE0100         ; if so handle the hit
  644.                     rts                 ; else DialogSelect did what was needed
  645.  
  646. MLE0100             ANOP
  647.                     _Sysbeep            ; beep on any selected item
  648.  
  649.                     rts                 ; go back to the event loop
  650.                     end
  651.  
  652.                     EJECT
  653. *******************************************************************************
  654. *
  655. ShowModeless        start
  656. *
  657. * Description:      Called when the user wants to display the modeless dialog.
  658. *                   If the dialog is already displayed, this routine does nothing.
  659. *
  660. *
  661. * Inputs:           None
  662. *
  663. * Outputs:          None
  664. *
  665. * External Refs:    None
  666. *
  667. * Entry Points:     None
  668. *
  669. *******************************************************************************
  670.                     using Globals
  671.  
  672.                     lda ModelessPtr     ; first test to see if box
  673.                     ora ModelessPtr+2   ; is already up
  674.                     beq DML0010         ; if 0 then its not up
  675.                     rts                 ; if nonzero then it is
  676. DML0010             ANOP
  677.                     PushLong #0         ; room for result
  678.                     PushLong #MLRect    ; bounds rect pointer
  679.                     PushLong #MLTitle   ; box title
  680.                     PushLong #-1        ; behind pointer (-1, in front of all)
  681.                     pushWord #fTitle+fClose+fMove+fVis ; dFlag
  682.                     PushLong #0         ; ref con of dialog
  683.                     PushLong #0         ; zoomed rectangle, 0= no zooming
  684.                     _NewModelessDialog
  685.                     PullLong ModelessPtr ; store the result in dialog ptr
  686.  
  687.                     PushLong ModelessPtr ; now add the dialog items
  688.                     PushLong #MLINext   ; first add the next button
  689.                     _GetNewDItem
  690.  
  691.                     PushLong ModelessPtr
  692.                     PushLong #MLIAll
  693.                     _GetNewDItem
  694.  
  695.                     PushLong ModelessPtr
  696.                     PushLong #MLIStat1
  697.                     _GetNewDItem
  698.  
  699.                     PushLong ModelessPtr
  700.                     PushLong #MLIStat2
  701.                     _GetNewDItem
  702.  
  703.                     PushLong ModelessPtr
  704.                     PushLong #MLIEdit1
  705.                     _GetNewDItem
  706.  
  707.                     PushLong ModelessPtr
  708.                     PushLong #MLIEdit2
  709.                     _GetNewDItem
  710.  
  711.                     PushWord #CloseItem ; we now have the dialog up so 
  712.                     _EnableMItem        ; enable the close menu item
  713.  
  714.                     rts
  715. MLINextStr          str 'Change Next'
  716. MLIAllStr           str 'Change All'
  717. MLIStat1Str         str 'Find Text:'
  718. MLIStat2Str         str 'Change to:'
  719. MLIDefault          str ''
  720. MLIEData1           dc i1'31'           ; data max will be 30 characters
  721. MLIEData2           dc i1'31'           ; data max will be 30 characters
  722. MLINext             ANOP                ; Item Templates
  723.                     dc i2'1'            ; Item 1
  724.                     dc i2'55,10,70,120' ; bounding rectangle
  725.                     dc i2'buttonItem'   ; Item Type
  726.                     dc i4'MLINextStr'   ; descriptor ( title )
  727.                     dc i2'0'            ; initial value
  728.                     dc i2'0'            ; item flag
  729.                     dc i4'BColorTab'    ; Custom color table
  730.  
  731. MLIAll              ANOP
  732.                     dc i2'2'
  733.                     dc i2'55,180,70,290'
  734.                     dc i2'buttonItem'
  735.                     dc i4'MLIAllStr'
  736.                     dc i2'0'
  737.                     dc i2'3'            ; Single outline square dropshadow
  738.                     dc i4'BColorTab'    ; Custom color table
  739.  
  740. MLIStat1            ANOP
  741.                     dc i2'3'
  742.                     dc i2'12,10,22,90'
  743.                     dc i2'statText+itemDisable'
  744.                     dc i4'MLIStat1Str'
  745.                     dc i2'0'
  746.                     dc i2'0'            ; item flag
  747.                     dc i4'0'            ; default color table
  748.  
  749. MLIStat2            ANOP
  750.                     dc i2'4'
  751.                     dc i2'32,10,42,90'
  752.                     dc i2'statText+itemDisable'
  753.                     dc i4'MLIStat2Str'
  754.                     dc i2'0'
  755.                     dc i2'0'            ; item flag
  756.                     dc i4'0'            ; default color table
  757.  
  758. MLIEdit1            ANOP
  759.                     dc i2'5'
  760.                     dc i2'10,100,25,290'
  761.                     dc i2'editLine+itemDisable'
  762.                     dc i4'0'            ; 0 for no default text
  763.                     dc i2'30'           ; maximum length
  764.                     dc i2'0'            ; item flag
  765.                     dc i4'0'            ; default color table
  766.  
  767. MLIEdit2            ANOP
  768.                     dc i2'6'
  769.                     dc i2'30,100,45,290'
  770.                     dc i2'editLine+itemDisable'
  771.                     dc i4'MLIDefault'   ; default string
  772.                     dc i2'30'
  773.                     dc i2'0'            ; item flag
  774.                     dc i4'0'            ; default color table
  775.  
  776.  
  777.                     end
  778.  
  779.                     EJECT
  780. *******************************************************************************
  781. *
  782. doModal             start
  783. *
  784. * Description:      Displays the modal Dialog and handles all events that
  785. *                   occur until the OK or Cancel buttons are pressed. If the
  786. *                   OK button is pressed, this routine also copies the current
  787. *                   data from some of the items into the item default area so
  788. *                   the next time the dialog box is brought up, it reflects the
  789. *                   users last selections.
  790. *
  791. *
  792. * Inputs:           None
  793. *
  794. * Outputs:          None
  795. *                                       
  796. * External Refs:    None
  797. *
  798. * Entry Points:     None
  799. *
  800. *******************************************************************************
  801.                     using Globals
  802.  
  803.                     PushLong #0         ; room for result
  804.                     PushLong #ModalTemplate ; pointer to dialog template
  805.                     _GetNewModalDialog
  806.                     PullLong DialogHandle ; pull Dialog pointer for later
  807.  
  808. ModalLoop           ANOP
  809.                     PushWord #0         ; Space for result
  810.                     PushLong #0         ; Filter procedure ( 0 for none )
  811.                     _ModalDialog
  812.                     pla
  813.                     sta ItemHit
  814.  
  815.                     cmp #3              ; test if its an exit condition
  816.                     blt ModalDone       ; is so, then we are done   
  817.                     cmp #7              ; see if the check box was hit
  818.                     bne ML0010          ; if not test more
  819.                     brl ModalCheckHit   ; the check box was hit
  820. ML0010              ANOP
  821.                     blt ModalRadioHit   ; one of the radio buttons was hit
  822.                     brl ModalLoop       ; This should bever happen!
  823.  
  824. ModalDone           ANOP
  825.                     cmp #1              ; was it the OK button?
  826.                     bne MD0020          ; no, then Don't save or act on changes
  827.                     jsr SetIt           ; else, reset defaults
  828. MD0020              ANOP
  829.                     PushLong DialogHandle ; get rid of the dialog box
  830.                     _CloseDialog
  831.                     rts
  832.  
  833. ModalRadioHit       ANOP
  834. ; This routine sets the selected radio button. NOTE: since the radio buttons
  835. ; have the same family number, this routine also resets the other buttons.
  836.  
  837.                     Pushword #$FFFF     ; now set selected button
  838.                     PushLong DialogHandle
  839.                     PushWord ItemHit
  840.                     _SetDItemValue
  841.                     brl ModalLoop
  842.  
  843. ModalCheckHit       ANOP                ; Handle a hit in the check box
  844.                     PushWord #0
  845.                     PushLong DialogHandle
  846.                     PushWord ItemHit
  847.                     _GetDItemValue      ; first get the existing value
  848.                     pla                 ; retrieve the value
  849.                     and #$0001          ; strip off all high bits
  850.                     eor #$0001          ; and toggle bit 0
  851.                     pha                 ; now use it as the new value
  852.                     PushLong DialogHandle
  853.                     PushWord ItemHit
  854.                     _SetDItemValue
  855.                     brl ModalLoop
  856.  
  857. SetIt               ANOP                ; ok was hit so retrieve
  858.                     PushWord #0         ; values and save them as default 
  859.                     PushLong DialogHandle ; in template for next time
  860.                     PushWord #5
  861.                     _GetDItemValue
  862.                     PullWord MTRad1Def
  863.  
  864.                     PushWord #0
  865.                     PushLong DialogHandle
  866.                     PushWord #6
  867.                     _GetDItemValue
  868.                     PullWord MTRad2Def
  869.  
  870.                     PushWord #0
  871.                     PushLong DialogHandle
  872.                     PushWord #7
  873.                     _GetDItemValue
  874.                     PullWord MTCheckDef
  875.  
  876.                     PushLong DialogHandle
  877.                     PushWord #8         ; now retrieve the text and use it
  878.                     PushLong #MTDefaultStr
  879.                     _GetIText
  880.                     rts
  881.  
  882. ItemHit             ds 2
  883. DialogHandle        ds 4
  884.                     end
  885.  
  886.                     END
  887.